<template>
  <div class="index">
    <ul class="top">
      <li class="left">{{ xuQiuNum }}</li>
      <li class="right">{{ gongYingNum }}</li>
    </ul>
    <ul class="bottom">
      <li>前端需求人数</li>
      <li>前端供应人数</li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      xuQiuNum: Math.floor(Math.random() * 1000000 + 1) // 需求人数
    };
  },
  computed: {
    // 生成供应人数
    gongYingNum() {
      return this.xuQiuNum - Math.floor(Math.random() * 1000 + 1);
    }
  },
  mounted() {
    setInterval(() => {
      this.getXuQiu();
    }, 3000);
  },
  methods: {
    /**
     * 随机生成需求人数
     */
    getXuQiu() {
      this.xuQiuNum = Math.floor(Math.random() * 1000000 + 1);
    }
  },
  beforeDestroy() {
    clearInterval(() => {
      this.getXuQiu(); // 需求人数
    });
  }
};
</script>

<style lang="scss" scoped>
.index {
  ul {
    list-style: none;
    display: flex;
    li {
      flex: 1;
      text-align: center;
      position: relative;
    }
  }
  ul:nth-child(1) {
    height: 80px;
    font-size: 70px;
    color: #ffeb7b;
    border: 1px solid rgba(25, 186, 139, 0.17);
  }
  .top {
    font-family: electronicFont;
    .left {
      &::before {
        // 使用伪元素做边框
        content: "";
        width: 30px;
        height: 10px;
        border-top: 1px solid #02a6b5;
        border-left: 1px solid #02a6b5;
        position: absolute;
        top: 0;
        left: 0;
      }
      &::after {
        // 小竖线
        content: "";
        width: 1px;
        height: 50%;
        background: rgba(255, 255, 255, 0.2);
        position: absolute;
        top: 25%;
        right: 0;
      }
    }
    .right {
      &::after {
        // 使用伪元素做边框
        content: "";
        width: 30px;
        height: 10px;
        border-bottom: 1px solid #02a6b5;
        border-right: 1px solid #02a6b5;
        position: absolute;
        bottom: 0;
        right: 0;
      }
    }
  }
  .bottom {
    color: rgba(255, 255, 255, 0.7);
    height: 40px;
    font-size: 18px;
    padding-top: 10px;
  }
}
</style>